package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 攻略目录
 */
@JsonIgnoreProperties("handler")
@Getter@Setter@ToString
public class StrategyCatalog extends BaseDomain {
    private String name;//名称

    private Strategy strategy;//对应的攻略

    private Integer sequence;//序号

    private Boolean state;//状态

    private List<StrategyDetail> details = new ArrayList<>();//攻略细节

    @JsonIgnore
    public String getJson(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        if (strategy != null) {
            map.put("strategyId",strategy.getId());
            map.put("strategyTitle",strategy.getTitle());
        }
        map.put("sequence",sequence);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }
}